﻿package fpc.utils;
import flash.utils.Dictionary;

class WrappedDictionary< K, T >
{
	var _dictionary:Dictionary;
	
	public function new(?weakKeys:Bool) 
	{
		_dictionary = new Dictionary(weakKeys);
	}
	
	public inline function get( k : K ) : Null<T> {
		return _dictionary[cast k];
	}

	public inline function set( k : K, v : T ) {
		_dictionary[cast k] = v;
	}

	public inline function exists( k : K ) {
		return _dictionary[cast k] != null;
	}

	public inline function delete( k : K ) {
		untyped __delete__(_dictionary,k);
	}

	public inline function keys() : Array<K> {
		return untyped __keys__(_dictionary);
	}

	public function iterator() : Iterator<K> {
		return keys().iterator();
	}
}